<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        ul li:first-child{
            background: red;
        }

        ul li:last-child{
            background: blue;
        }

        p:nth-child(2){
            background: yellow;
        }

        p:nth-of-type(2){
            background: green;
        }
    </style>

</head>
<body>

<h2>h2</h2>
<p>p1</p>
<p>p2</p>
<p>p3</p>
<ul>
    <li>li1</li>
    <li>li2</li>
    <li>li3</li>
</ul>

</body>
</html>